
package com.job;

import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SchedulerMetaData;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Hello world!
 */
public class App {

	private static final Logger LOG = LoggerFactory.getLogger(App.class);

	public void run()
		throws Exception {

		// First we must get a reference to a scheduler
		Scheduler sched = StdSchedulerFactory.getDefaultScheduler();

		LOG.info("------- Initialization Complete -----------");
		LOG.info("------- (Not Scheduling any Jobs - relying on XML definitions --");
		LOG.info("------- Starting Scheduler ----------------");

		// start the schedule
		sched.start();

		LOG.info("------- Started Scheduler -----------------");
		LOG.info("------- Waiting five minutes... -----------");

		// wait five minutes to give our jobs a chance to run
		try {
			Thread.sleep(300L * 1000L);
		}
		catch (Exception e) {
		}

		// shut down the scheduler
		LOG.info("------- Shutting Down ---------------------");
		sched.shutdown(true);
		LOG.info("------- Shutdown Complete -----------------");

		SchedulerMetaData metaData = sched.getMetaData();
		LOG.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");
	}

	public static void main(String[] args)
		throws Exception {

		App example = new App();
		example.run();
	}
}
